#ifndef _CAN_H_
#define _CAN_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "cs_types.h"

enum {
    CAN,
    CANFD,
};

enum {
    CAN_TYPE_CAN_9120,
    CAN_TYPE_CAN_9140,
    CAN_TYPE_CANFD_200U,
    CAN_TYPE_CANFD_400U,
    CAN_TYPE_USB_PCAN,
    CAN_TYPE_USB_CAN_ALYSTII,
    CAN_TYPE_COUNT,
};

enum {
    CAN_FRAME_TYPE_STANDARD = 0,
    CAN_FRAME_TYPE_EXTEND = 1,
};

Handler cs_can_get_handler(U8 boardid, U8 chann);
void cs_can_set_handler(U8 boardid, U8 chann, Handler h);
Handler cs_can_init(U8 boardid, U8 devtype, U8 chnn, int baud, int dbbaud, int sp, int dsp);
int cs_can_uninit(Handler h);
int cs_can_send(Handler h, U8 protocol, U8 frametype, U32 frameid, const unsigned char *data, int len, int timeoutus);
int cs_can_recv(Handler h, U8 mb_id, U8 protocol, U8 frametype, U32 frameid, unsigned char *data, int len, int timeoutus);

int cs_can_mailbox_reg(Handler h, int mb_id, int id);
int cs_can_mailbox_unreg(Handler h, int mb_id);


#ifdef __cplusplus
}
#endif

#endif
